
//#import "AppDelegate.h"

/*----------------开发中常用到的宏定义-----------------*/
#define iOS7  ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )

/// 预编译函数体
#define NotContain(source,dest) [source rangeOfString:dest].location==NSNotFound
#define IsEmpty(source) !(source&&source.length>0)
#define IsNull(source) [source isKindOfClass:[NSNull class]]
#define IsPhone UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone
#define IsPad UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad
#define LocStr(key) NSLocalizedString(key,@"")

#define NS_USERDEFAULT [NSUserDefaults standardUserDefaults]

#define mNavBarHeight         44
#define mTabBarHeight         49

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define mScreenWidth          ([UIScreen mainScreen].bounds.size.width)
#define mScreenHeight         ([UIScreen mainScreen].bounds.size.height)


#define mIsPad    (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define mIsiphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
//系统版本
#define mSystemVersion   ([[UIDevice currentDevice] systemVersion])
#define mCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
#define mAPPVersion      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define mFirstLaunch     mAPPVersion     //以系统版本来判断是否是第一次启动，包括升级后启动。
#define mFirstRun        @"firstRun"     //判断是否为第一次运行，升级后启动不算是第一次运行
//#define UIButtonType        UIButtonTypeCustom

//设置导航控制器的标题
#define NAVTITLE(TITLE)    self.navigationItem.title = TITLE

//TODO:字体
#define UIFONT(size)      [UIFont systemFontOfSize:size]
#define UIFONT_bold(size)      [UIFont boldSystemFontOfSize:size]


//TODO:沙盒文件处理
#define SETUSERID(userId)  \
{ \
[[NSUserDefaults standardUserDefaults] setObject:userId forKey:@"myuserID"]; \
[[NSUserDefaults standardUserDefaults] synchronize];\
}  //保存用户ID
#define CURRENTUSERID  [[NSUserDefaults standardUserDefaults] objectForKey:@"myuserID"] //获取用户ID


#define SETDEVICEID(deviceid)  \
{ \
[[NSUserDefaults standardUserDefaults] setObject:deviceid forKey:@"deviceid"]; \
[[NSUserDefaults standardUserDefaults] synchronize];\
}//保存设备ID
#define CURRENTDEVICEID  [[NSUserDefaults standardUserDefaults] objectForKey:@"deviceid"]//获取设备ID


//TODO:获取颜色
UIKIT_STATIC_INLINE UIColor *toPCcolor(NSString *pcColorstr)
{
    unsigned int c;
    
    if ([pcColorstr characterAtIndex:0] == '#') {
        
        [[NSScanner scannerWithString:[pcColorstr substringFromIndex:1]] scanHexInt:&c];
        
    } else {
        
        [[NSScanner scannerWithString:pcColorstr] scanHexInt:&c];
        
    }
    
    return [UIColor colorWithRed:((c & 0xff0000) >> 16)/255.0 green:((c & 0xff00) >> 8)/255.0 blue:(c & 0xff)/255.0 alpha:1.0];
}
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored "-Warc-performSelector-leaks"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

//TODO:默认图片设置
#define PlaceHeaderImage @"340.png"
#define PlaceHeaderSquareImage @"340.png"
#define PlaceHeaderBigSquareImage @"720.png"
#define PlaceHeaderRectangularImage @"750x380.png"
#define PlaceHeaderIconImage @"icon512.png"

//TODO:适配相关
//#import "UIViewExt.h" // 相对布局

/*判断iphone设备，通过设备的屏幕进行判断*/
#define  iPhone4   (\
CGSizeEqualToSize( [UIScreen mainScreen].bounds.size , CGSizeMake(320, 480)) || CGSizeEqualToSize( [UIScreen mainScreen].bounds.size , CGSizeMake(640, 960)) \
)


#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242,2208), [[UIScreen mainScreen] currentMode].size) : NO)

//如果能执行（currentMode）就说明可以像素来区分，如果等于就返回YES
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)




//获取设备的物理宽度
#define deviceWidth ([UIScreen mainScreen].bounds.size.width)
#define deviceHeight ([UIScreen mainScreen].bounds.size.height)

/*判断系统是否是IOS7*/
#define isIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ? YES:NO)

#define iOS7Later        [[KKSource getSystemVersion] floatValue] > 6.5f ? YES : NO

#define iOS8Later ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 ? YES:NO)


/*起始坐标的Y值*/
/*
 从状态栏下开始算起
 如果view的Y坐标为状态栏以下50像素，CGRectMake(0,startOriginY+50,0,0)
 */
#define startOriginY ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ? 20:0)
//自定义上导航栏高度为44
#define navigationBarHeight 64.0

// 字符串扩展
//#import "NSString+Extension.h"

//屏幕的坐标
#define ORIGIN_X        [UIScreen mainScreen].bounds.origin.x
#define ORIGIN_Y        [UIScreen mainScreen].bounds.origin.y

//UITableViewCell的坐标
#define TableCell_X       self.contentView.frame.origin.x
#define TableCell_Y       self.contentView.frame.origin.y
#define TableCell_Width   self.contentView.frame.size.width
#define TableCell_Height  self.contentView.frame.size.height




